package com.springcloud.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.entity.Dep;
import com.google.gson.Gson;
import com.springcloud.controller.DepController;
import com.springcloud.dao.DepDao;
import com.springcloud.service.DepService;

@Service
public class DepServiceImpl implements DepService{
	
	public static final Logger log = LoggerFactory.getLogger(DepController.class);
	
	@Autowired
	private DepDao DepDao;
	
	@Override
	public Dep queryDepByDepNo(Integer depno) {
		try {
			Dep dep = DepDao.queryDepByDepNo(depno);
			log.info("queryDepByDepNo 查询结果  为 {}", new Gson().toJson(dep));
			return dep;
		} catch (Exception e) {
			log.info("查询异常 ", e.getMessage(), e);
		}
		return null;
	}
	
	@Override
	public List<Dep> queryAll() {
		try {
			List<Dep> list = DepDao.queryAll();
			log.info("queryAll 查询结果  为 {}", new Gson().toJson(list));
			return list;
		} catch (Exception e) {
			log.info("查询异常 ", e.getMessage(), e);
		}
		return null;
	}

}
